home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
brent_cc.lha
/
brent_cc
/
math_num.h
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-08
|
2KB
|
81 lines
// This may look like C code, but it is really -*- C++ -*-
/*
************************************************************************
*
* Numerical Math Package
*
* The present package implements various algorithms of Numerical Math
*
************************************************************************
*/
#pragma once
#pragma interface
#include "myenv.h"
#include <math.h>
#include <std.h>
/*
*------------------------------------------------------------------------
* Some constants
* Compile and run the program epsilon.c to determine the values below for
* your computer
*/
#define EPSILON 2.22045e-16
#define SQRT_EPSILON 1.49012e-08
/*
*------------------------------------------------------------------------
* Brent's minimum and zero finders for
* a function of a single argument
*/
// Obtain a zero of function f
// over the range [ax,bx] with the
// accuracy tol.
double zeroin(const double ax, const double bx,
double (*f)(const double x), const double tol=EPSILON);
// Find a minimum of function f
// over the range [a,b] with the
// accuracy tol.
// Returns an approx. to the min location
double fminbr(const double a, const double b,
double (*f)(const double x), const double tol=EPSILON);
#ifdef REAL
/*
*------------------------------------------------------------------------
* Interpolation of the function
* specified in the tabular form
*/
// Aitken-Lagrange interpolation to the
// point q over the table of function values
// y[i] = y(x[i]), i = y.lwb..y.upb
overload ali;
// Uniform mesh x[i] = x0 + s*(i-y.lwb)
double ali(const double q, const double x0, const double s, const Vector& y);
// Nonuniform grid with nodes in x[i]
double ali(const double q, const Vector& x, const Vector& y);
/*
*------------------------------------------------------------------------
* Multi-dimensional minimization
*/
// Find a local minimum of a given
// function by the Hook-Jeevse method
double hjmin( // Return the function value at min
Vector& b, // On input - initial guess to min loc
// On output - loc for the min found
const Vector& h0, // Initial values for the steps along
// each direction
double (*f)(const Vector& x) // Procedure to compute a function
// value at the specified point
);
#endif